package com.hevery.beans.io;

import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * @description: 根据输入的Url来获取资源
 * @author: hongyu.zhang
 * @create: 2018-03-20
 **/
public class UrlResource implements Resource {
    private URL url;
    public UrlResource(URL url){
        this.url = url;
    }
    @Override
    public InputStream getInputStream() throws Exception{
        URLConnection urlConnection = url.openConnection();
        urlConnection.connect();
        return urlConnection.getInputStream();
    }
}
